package com.boot2.core.constant;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangweilin
 * @description: 支付渠道常量
 * @date 2018/10/4
 */
public class PayEnum {

    public static enum PayChannel {
        /**
         * 支付渠道
         */
        alipayMobile("alipay", "支付宝移动"),
        alipayPc("alipay", "支付宝PC"),
        alipayWap("alipay", "支付宝WAP"),
        alipayQr("alipay", "支付宝当面付之扫码"),
        wxJsapi("wx", "微信公众号"),
        wxNative("wx", "微信原生扫码"),
        wxApp("wx", "微信APP"),
        wxMweb("wx", "微信H5"),
        paypalPc("paypal", "paypal pc"),
        iap("iap", "苹果应用内");

        public static final Map<String, String> valueMap = new HashMap<>();
        public static final List<Map<String, String>> valueList = new ArrayList<>();

        static {
            for (PayChannel payChannel : PayChannel.values()) {
                valueMap.put(payChannel.channelType, payChannel.channelCodeText);

                Map<String, String> valueMap1 = new HashMap<>(1);
                valueMap1.put(payChannel.channelType, payChannel.channelCodeText);
                valueList.add(valueMap1);
            }
        }

        /**
         * 支付渠道类型，如alipay(包括移动支付，二维码支付，pc网页支付等)
         */
        private String channelType;
        /**
         * 对应的支付渠道名称
         */
        private String channelCodeText;


        private PayChannel(String channelType, String channelCodeText) {
            this.channelType = channelType;
            this.channelCodeText = channelCodeText;
        }

        public static PayChannel getByName(String name) {
            for (PayEnum.PayChannel c : PayEnum.PayChannel.values()) {
                if (c.name().equalsIgnoreCase(name)) {
                    return c;
                }
            }
            return null;
        }

        public String getChannelType() {
            return channelType;
        }

        public void setChannelType(String channelType) {
            this.channelType = channelType;
        }

        public String getChannelCodeText() {
            return channelCodeText;
        }

        public void setChannelCodeText(String channelCodeText) {
            this.channelCodeText = channelCodeText;
        }
    }


    public static enum Currency {
        /**
         * 各货币
         */
        CNY("CNY", "￥"),
        USD("USD", "$"),
        CA("CA", "$"),
        GBP("GBP", "￡"),
        EUR("EUR", "€");

        public static final Map<String, String> valueMap = new HashMap<>();
        public static final List<Map<String, String>> valueList = new ArrayList<>();

        static {
            for (Currency payChannel : Currency.values()) {
                valueMap.put(payChannel.code, payChannel.symbol);

                Map<String, String> valueMap1 = new HashMap<>(1);
                valueMap1.put(payChannel.code, payChannel.symbol);
                valueList.add(valueMap1);
            }
        }

        /**
         * 货币代码
         */
        private String code;
        /**
         * 货币代码及符号
         */
        private String symbol;


        private Currency(String code, String symbol) {
            this.code = code;
            this.symbol = symbol;
        }

        public static Currency getByName(String name) {
            for (Currency c : Currency.values()) {
                if (c.name().equalsIgnoreCase(name)) {
                    return c;
                }
            }
            return null;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getSymbol() {
            return symbol;
        }

        public void setSymbol(String symbol) {
            this.symbol = symbol;
        }
    }
}
